﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Test.Window
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            test t = new test();
            var entity = t.GetType().GetProperty("ts");
            MessageBox.Show(t.GetType().Name);
            /*this.richTextBox1.Text =Convert.ToBase64String(rsa.Encrypt(System.Text.UnicodeEncoding.Unicode.GetBytes("KE"), true));
            this.richTextBox2.Text = Convert.ToBase64String(rsa.Encrypt(System.Text.UnicodeEncoding.Unicode.GetBytes("KE"), true));
            PK = rsa.ToXmlString(true);*/
        }

        RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

        String PK;
        private void button1_Click(object sender, EventArgs e)
        {

            RSACryptoServiceProvider rsa1 = new RSACryptoServiceProvider();
            try
            {
                rsa1.Clear();
                rsa1.FromXmlString(PK);
                MessageBox.Show(System.Text.UnicodeEncoding.Unicode.GetString(rsa1.Decrypt(
                    Convert.FromBase64String(this.richTextBox1.Text), true)));
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show(System.Text.UnicodeEncoding.Unicode.GetString(rsa.Decrypt(
                 Convert.FromBase64String(this.richTextBox1.Text), true)));
        }
    }

    public class test
    {
        public String ts { get { return "tss"; } }
    }
}
